DotNet Example: Image metadata class

Description

When writing an Xbasic function that uses the .NET Framework, you always have the option of writing or using a custom .NET class that gives you a simplified interface compared to using the .NET Framework classes directly. This example demonstrates extracting EXIF information from an image using the Exifacto .NET library.

The following script assumes that you have either checked out the project (click here to download the project) or downloaded the Exifacto DLL.

dim sv as dotnet::services
dim assy as dotnet::assemblyreference
 
'edit the path to the DLL in the next line
assy.FileName = "C:\path\to\Exifacto.dll" 
sv.RegisterAssembly("exif",assy)
 
'edit the path to the image in the next line
filename="C:\full\path\to\image\file"
 
ex = new exif::Exifacto::exifdata(filename)
 
CameraMake=ex.CameraMake
CameraModel=ex.CameraModel
Copyright=ex.Copyright
DateTimeOriginal=ex.DateTimeOriginal
ImageDescription=ex.ImageDescription
Orientation=ex.Orientation.value__
ExposureProgram=ex.ExposureProgram.value__
Software=ex.Software
 
'show selected properties
exif_data = filename + \
    crlf()+"Camera: "+CameraMake+" "+CameraModel+" taken "+DateTimeOriginal+ \
    crlf()+"Description: "+ImageDescription+crlf()+"Copyright: "+Copyright+ \
    crlf()+"Orientation: "+Orientation+" ExposureProgram: "+ExposureProgram+ \
    crlf()+"Software: "+Software

ui_msg_box("exif",exif_data)
 
showvar(ex) 'show all properties

See Also